package com.zx.controller;

import com.zx.entity.User;
import com.zx.service.IndexInte;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 程仟磊
 * @date 2021/7/27
 */
@Controller
public class Indexc {
    @Resource
    private IndexInte indexInte;
    //加载一级菜单
    @ResponseBody
    @RequestMapping("/loadFMenu")
    public List loadFMenu(HttpSession httpSession){
        Integer uid = Integer.valueOf(String.valueOf(httpSession.getAttribute("uid")));
        return  indexInte.loadFMenu(uid);
    }
    //加载二级菜单
    @ResponseBody
    @RequestMapping("/loadTMenu")
    public List loadTMenu(HttpSession httpSession,String mparent){
        Integer uid = Integer.valueOf(String.valueOf(httpSession.getAttribute("uid")));
        return  indexInte.loadTMenu(uid,mparent);
    }
    @ResponseBody
    @RequestMapping("/loadFMenu2")
    public void  loadFMenu2(HttpSession httpSession, HttpServletRequest request){
        Integer uid = Integer.valueOf(String.valueOf(httpSession.getAttribute("uid")));
        List list = indexInte.loadFMenu(uid);
        request.setAttribute("list",list);

    }
    @ResponseBody
    @RequestMapping("/findUserName")
    public Object findUserName(HttpSession httpSession){
        String user = String.valueOf(httpSession.getAttribute("user"));
        User user1=new User();user1.setUsname(user);
        return user1;
    }

}
